-
Notifications
You must be signed in to change notification settings - Fork 795
[SYCL] Add SPIR-V atomic builtins declarations to clang/lib/Sema/SPIRVBuiltins.td #17471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SYCL] Add SPIR-V atomic builtins declarations to clang/lib/Sema/SPIRVBuiltins.td #17471
Conversation
…PIRVBuiltins.td Change scope and memory semantics type from Enum from int, similar as in PR intel#17438. volatile is removed from function parameter pointer type, to align with SVP-IR and clang/lib/Sema/SPIRVBuiltins.td.
When long long and another type, e.g. long, are used in a same test, there is error: sycl/__spirv/spirv_ops.hpp:337:17: note: candidate function not viable: no known conversion from 'long *' to '__global long long *' for 1st argument
frasercrmck
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thank you!
Should there be clang tests for these new builtins? I've not really been following the upstream clang/SPIR-V side of things.
| __SPIRV_ATOMICS(__SPIRV_ATOMIC_FLOAT, _Float16) | ||
| __SPIRV_ATOMICS(__SPIRV_ATOMIC_FLOAT, float) | ||
| __SPIRV_ATOMICS(__SPIRV_ATOMIC_FLOAT, double) | ||
| __SPIRV_ATOMICS(__SPIRV_ATOMIC_SIGNED, int) | ||
| __SPIRV_ATOMICS(__SPIRV_ATOMIC_SIGNED, long) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remove this part and below unsigned int/long variants because when a test uses both long long type from this header and non-long long type from clang SPIRVBuiltins.td, there is build error
using AtomicRefT =
atomic_ref<long long, memory_order::relaxed, memory_scope::device>;
using AtomicRefT2 =
atomic_ref<long, memory_order::relaxed, memory_scope::device>;
In file included from Regression/pf-wg-atomic64.cpp:9:
In file included from intel-llvm/build/bin/../include/sycl/atomic_ref.hpp:13:
In file included from intel-llvm/build/bin/../include/sycl/ext/oneapi/experimental/address_cast.hpp:11:
intel-llvm/build/bin/../include/sycl/detail/spirv.hpp:654:10: error: no matching function for call to '__spirv_AtomicIAdd'
654 | return __spirv_AtomicIAdd(Ptr, SPIRVScope, SPIRVOrder, Value);
| ^~~~~~~~~~~~~~~~~~
intel-llvm/build/bin/../include/sycl/atomic_ref.hpp:311:27: note: in instantiation of function template specialization 'sycl::detail::spirv::AtomicIAdd<long, sycl::access::address_space::generic_space, sycl::access::decorated::no>' requested here
311 | return detail::spirv::AtomicIAdd(ptr, scope, order, operand);
| ^
intel-llvm/build/bin/../include/sycl/atomic_ref.hpp:319:12: note: in instantiation of member function 'sycl::detail::atomic_ref_impl<long, 4, sycl::memory_order::relaxed, sycl::memory_scope::device, sycl::access::address_space::generic_space>::fetch_add' requested here
319 | return fetch_add(operand) + operand;
| ^
Regression/pf-wg-atomic64.cpp:45:19: note: in instantiation of member function 'sycl::detail::atomic_ref_impl<long, 4, sycl::memory_order::relaxed, sycl::memory_scope::device, sycl::access::address_space::generic_space>::operator+=' requested here
45 | feature += 42;
| ^
intel-llvm/build/bin/../include/sycl/__spirv/spirv_ops.hpp:337:17: note: candidate function not viable: no known conversion from 'long *' to '__global long long *' for 1st argument
337 | __SPIRV_ATOMICS(__SPIRV_ATOMIC_SIGNED, long long)
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
intel-llvm/build/bin/../include/sycl/__spirv/spirv_ops.hpp:334:3: note: expanded from macro '__SPIRV_ATOMICS'
334 | macro(__attribute__((opencl_global)), Arg) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
intel-llvm/build/bin/../include/sycl/__spirv/spirv_ops.hpp:303:3: note: expanded from macro '__SPIRV_ATOMIC_SIGNED'
303 | __SPIRV_ATOMIC_BASE(AS, Type) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
intel-llvm/build/bin/../include/sycl/__spirv/spirv_ops.hpp:296:3: note: expanded from macro '__SPIRV_ATOMIC_BASE'
296 | __SPIRV_ATOMIC_IADD(AS, Type) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
intel-llvm/build/bin/../include/sycl/__spirv/spirv_ops.hpp:249:37: note: expanded from macro '__SPIRV_ATOMIC_IADD'
249 | extern __DPCPP_SYCL_EXTERNAL Type __spirv_AtomicIAdd( \
| ^
Please advise how to proceed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's linked to this I think https://github.com/intel/llvm/pull/1384/files#diff-73b1c844b6929ccc37836285e2d87f89ead7074c6693a80e712f06bb54fa5cb2, I'll need to refresh my memory and come back to you as it is a bit old now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll keep the declarations in sycl/include/sycl/__spirv/spirv_ops.hpp until there is a stable solution. I'll check it later.
elizabethandrews
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add FE tests
added in e630132 |
steffenlarsen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
|
@intel/dpcpp-cfe-reviewers please review again, thanks |
|
@intel/llvm-gatekeepers please merge, thanks |
| extern __DPCPP_SYCL_EXTERNAL Type __spirv_AtomicXor( \ | ||
| AS Type *P, __spv::Scope::Flag S, __spv::MemorySemanticsMask::Flag O, \ | ||
| Type V); | ||
| extern __DPCPP_SYCL_EXTERNAL Type __spirv_AtomicXor(AS Type *P, int S, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my education, why do we still need these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aelovikov-intel it is related to long long type, please check comment: #17471 (comment)
Change scope and memory semantics type from Enum from int, similar as in PR #17438.
volatile/const is removed from function parameter pointer type, to align with SVP-IR and clang/lib/Sema/SPIRVBuiltins.td.